const Koa = require('koa');
const path = require('path');
const koaStatic = require('koa-static')
const koaRouter = require('koa-router')
const exec=require('child_process').execFile
const app = new Koa();
const router = new koaRouter()


router.post('/git', async (ctx, next) => {
    await next()
    ctx.body='accept post'
    const file='/data/myProject/Resume/build.sh'
    exec(file,(err,stdout,stderr)=>{
        if(err){
            ctx.body='accept post err'
        }
        ctx.body='accept post success'
    })
})

app.use(router.routes())
app.use(router.allowedMethods())
app.use(koaStatic(path.resolve(__dirname, '../www')));
app.listen(3000);
console.log('server start on port 3000');
